using DiLu.Expansion.File.Configs;
using FluentFTP;

namespace DiLu.Expansion.File.Operates.FTP.Configs;

/// <summary>
///     保存文件流到FTP配置
/// </summary>
public record SaveFileStreamToFtpConfig : SaveFileStreamConfig
{
    /// <summary>
    ///     文件流保存到FTP配置
    /// </summary>
    /// <param name="rootDirectory">根目录</param>
    /// <param name="fileGroupName">文件分组名称</param>
    /// <param name="fileStream">文件流</param>
    /// <param name="fileExtension">文件扩展名</param>
    /// <param name="ftpClient">FTP客户端</param>
    /// <param name="autoCloseFtpClient">
    ///     自动关闭FTP客户端 默认自动关闭客户端连接
    ///     如果为false需要自行调用 CloseFtpClientConnectAsync()方法
    /// </param>
    public SaveFileStreamToFtpConfig(string rootDirectory, string fileGroupName,
        Stream fileStream, string fileExtension, AsyncFtpClient ftpClient, bool autoCloseFtpClient) :
        base(rootDirectory, fileGroupName, fileStream, fileExtension)
    {
        ArgumentNullException.ThrowIfNull(ftpClient, nameof(ftpClient));
        FtpClient = ftpClient;
        AutoCloseFtpClient = autoCloseFtpClient;
    }

    /// <summary>
    ///     FTP客户端
    /// </summary>
    public AsyncFtpClient FtpClient { get; }

    /// <summary>
    ///     自动关闭FTP客户端
    /// </summary>
    public bool AutoCloseFtpClient { get; }
}